<script>
export default {
  name: "Login",
  methods: {
    loginHandler(){
        const adminName=this.$refs.adminName.value.trim();
        const password=this.$refs.password.value.trim();
        if(adminName.length>0 && password.length>0) {
            this.$store.dispatch('login', {
              adminName,
              password
            })
        }else{
          alert("请输入账号和密码")
        }
    }
  }
}
</script>

<template>
  <form>
    <p>管理员账号: <input ref="adminName" type="text"></p>
    <p>管理员密码: <input ref="password" type="password"></p>
    <button @click.prevent="loginHandler">登录</button>
  </form>
</template>

<style scoped>

</style>